#ifndef WSYRING_H
#define WSYRING_H
#define _USE_MATH_DEFINES

#include "geometry/vertex2d.h"
#include "QtGui/QOpenGLFunctions"
#include "geometry/wsyface.h"
#include <QObject>

/** 王诗阳圆环对象 */
class WSYRing : public QObject {
public:
    WSYRing(double radius1, double radius2, int segment) {
        vertices = new QList<GLfloat *>();
        faces = new QList<WSYFace *>();
        edges = new QList<GLint *>();
        edgeCounts = new QList<int>();

        smallerRing = new QList<GLfloat *>();
        largerRing = new QList<GLfloat *>();

        this->segment = segment;
        radius1 = abs(radius1); radius2 = abs(radius2);
        if (radius1 == radius2) {
            smallerRadius = radius1;
            largerRadius = radius1 + 10;
        } else {
            if (radius1 < radius2) {
                smallerRadius = radius1;
                largerRadius = radius2;
            } else {
                smallerRadius = radius2;
                largerRadius = radius1;
            }
        }
    }

    /** 获取所有的节点 */
    virtual QList<GLfloat *> *getVertices() {
        return vertices;
    }

    virtual GLfloat *getVertexOfIndex(int index) {
        return vertices->at(index);
    }

    virtual QList<GLint *> *getEdges() {
        return edges;
    }

    virtual QList<int> *getEdgeCounts() {
        return edgeCounts;
    }

    virtual void generate();
private:
    int segment;
    double smallerRadius, largerRadius;
    QList<WSYFace *> *faces; //面
    QList<GLfloat *> *vertices; //顶点
    QList<GLfloat *> *smallerRing; //小圆环
    QList<GLfloat *> *largerRing; //大圆环
    QList<GLint *> *edges; //边缘
    QList<int> *edgeCounts;
};

#endif // WSYRING_H
